package dS.ProjectGPS.NTrip;

import javax.microedition.lcdui.*;

public class FormNTripClient extends Form
{
     TextField Username = new TextField("Username", NTripClient.USER_NAME, 50, TextField.ANY);
     TextField Server = new TextField("Server", NTripClient.HOST_NAME, 50, TextField.URL);
     TextField Password = new TextField("Password", NTripClient.USER_PASS, 50, TextField.PASSWORD);
     TextField Port = new TextField("Port", Integer.toString(NTripClient.HTTP_PORT), 50, TextField.NUMERIC);
     TextField Mountpoint = new TextField("Current Mountpoint", NTripClient.MOUNT_POINT, 50, TextField.ANY);
     Ticker ticker1 = new Ticker("Enter settings to NTripCaster here...");

     public FormNTripClient()
     {
          super("Server Settings");
          try
          {
               NDSInit();
          }
          catch (Exception ex)
          {
          }
     }

     public void NDSInit() throws Exception
     {
          append(Server);
          append(Port);
          append(Username);
          append(Password);
          Password.setLayout(Item.LAYOUT_DEFAULT);
          Server.setPreferredSize(-1, -1);
          setTicker(ticker1);
          append(Mountpoint);
     }

     public void update(){
       Username.setString(NTripClient.USER_NAME);
       Server.setString(NTripClient.HOST_NAME);
       Password.setString(NTripClient.USER_PASS);
       Port.setString("" + NTripClient.HTTP_PORT);
       Mountpoint.setString(NTripClient.MOUNT_POINT);
     }

     public void save(){
       NTripClient.USER_NAME = Username.getString();
       NTripClient.HOST_NAME = Server.getString();
       NTripClient.USER_PASS = Password.getString();
       NTripClient.HTTP_PORT = Integer.parseInt(Port.getString());
       NTripClient.MOUNT_POINT = Mountpoint.getString();
     }
}
